package edu.qd.learn.newchapter.chapter03;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * 电子商务
 * 价格 ： 实例
 * 名称 ： 实例
 * 描述 ： 实例
 * 折扣 ： 实例
 * 6个原则   开闭
 *
 *
 * 厂家 : 
 *
 *
 *
 * @author 布衣
 */
public class Product {

    //唯一值
    private static int id;

    private BigDecimal price;

    private String name;

    private String desc;

    private BigDecimal discount;

    public Product() {
    }

    public Product(BigDecimal price, String name, String desc, BigDecimal discount) {
        this.price = price;
        this.name = name;
        this.desc = desc;
        this.discount = discount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Product product = (Product) o;
        return Objects.equals(price, product.price) && Objects.equals(name, product.name) && Objects.equals(desc, product.desc) && Objects.equals(discount, product.discount);
    }

    @Override
    public int hashCode() {
        return Objects.hash(price, name, desc, discount);
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public BigDecimal getDiscount() {
        return discount;
    }

    public void setDiscount(BigDecimal discount) {
        this.discount = discount;
    }

    public int getId() {
        return ++id;
    }

    @Override
    public String toString() {
        return "Product{" +
                "price=" + price +
                ", name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                ", discount=" + discount +
                '}';
    }

    public static void main(String[] args) {
        Product product = new Product();

        Product product1 = new Product();

        Product product2 = new Product();

        System.out.println(product2.getId());
        System.out.println(product1.getId());
        System.out.println(product.getId());
    }
}
